

<!DOCTYPE HTML>
<html>
<head> 
<title>XMLHttpRequest Example</title> 
<script language="javascript"> 
var xmlhttp=false;
var ds="";
/*@cc_on @*/
 
/*@if (@_jscript_version >= 5)
 
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
 
@else
 
	xmlhttp = false;
 
@end @*/

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 
	try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
 
}
 
function loadDoc(docname) {
 
	if (xmlhttp) {
		if(xmlhttp.withCredentials !== undefined) {
			
			xmlhttp.open("GET", docname,true);
			xmlhttp.witCredentials = true;
			 xmlhttp.onreadystatechange=function() {
			  if (xmlhttp.readyState==4) {
				   ds=xmlhttp.responseText;
			   document.forms[0].textArea1.value=ds+ds.length;
			  }
			 }
			 xmlhttp.send(null)
		 }
		 else {
			//
			xmlhttp.open("GET", docname,true);
			 xmlhttp.onreadystatechange=function() {
			  if (xmlhttp.readyState==4) {
				   ds=xmlhttp.responseText;
			   document.forms[0].textArea1.value=ds+ds.length;
			  }
			 }
			 xmlhttp.send(null)
		 }
	 } 
	 else {
		document.write("failed in XHR");
	 }
 
}
</script> 
<style> 
body, td {
	font-family: Arial;
	font-size: 13px;
	}
</style> 
</head> 
 
<body> 
<h1>XMLHttpRequest Example</h1> 
<h4>This script uses XMLHttpRequest, Javascript and HTML to load Readme.txt from the server dynamically.</h4> 
<form name=form1> 
<p><textarea cols=60 rows=8 name=textArea1>Watch me change when you press a button!</textarea></p> 
<p><input type=button value="Load Readme.txt" onClick="loadDoc('http://api-pub.dictionary.com/v001?vid=gi6mmn5fmidijlc9thyhokl8z0fdtby9t4wgs2wek9&q=esoteric&type=synonyms');"></p> 
</form> 
 
<p><a href='index.html'>Example 1</a> | <a href='example2.html'>Example 2</a> 
  | <a HREF="indextimer.html">Example 3 with Timeout</a></p> 
 
<p><a href='http://bugninja.blogspot.com'>bugninja</a></p> 
 
</body> 
</html> 